package cn.kivensoft.xlsx.helper;

import java.util.Date;
import java.util.Random;

public class Example {
	public static void main(String[] args) throws Exception {
		if (args.length == 0) {
			System.out.println("Usage: program <filename>");
			return;
		}

		XlsxExport xe = new XlsxExport("导  '\"出页");
		xe.setTitle("警情  '\"<报表>", new String[] {
				"统计时间: 2019-01-01 至 2019-12-31", "&打印日期: 2019-02-01"
		}, new int[] {3, 3}, new String[] {
				"ID", "警情时间", "警情地址", "报警电话", "通知人数", "到场人数"
		}, new float[] {
				8, 20, 40, 13, 8, 8
		});
		
		Random r = new Random();
		
		for (int i = 1; i <= 100; i++) {
			xe.goToNextRow();
			xe.addNextCell(i);
			xe.addNextCellDateTime(new Date());
			xe.addNextCell("海南省海口市美兰区文明中路100号");
			xe.addNextCell("15603334444");
			int n = r.nextInt(1000) + 1;
			xe.addNextCell(n);
			xe.addNextCell(r.nextInt(n));
		}
		
		xe.addWorkSheet("第二页");
		xe.setTitle("警情报表", null, null, new String[] {
				"ID", "警情时间", "警情地址", "报警电话", "通知人数", "到场人数"
		}, new float[] { 8, 20, 40, 13, 8, 8 });
		
		for (int i = 1; i <= 100; i++) {
			xe.goToNextRow();
			xe.addNextCell(i);
			xe.addNextCellDateTime(new Date());
			xe.addNextCell("海南省海口市美兰区文明中路");
			xe.addNextCell("13801033232");
			int n = r.nextInt(1000) + 1;
			xe.addNextCell(n);
			xe.addNextCell(r.nextInt(n));
		}

		xe.save(args[0]);
	}
}
